package com.pubinfo.passbook.api.controller.contract;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pubinfo.passbook.common.entity.TContractWbsProject;
import com.pubinfo.passbook.common.model.dto.contract.QueryWbsProjectParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.service.contract.TContractWbsProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@Api(tags = "QGPB-WBS项目管理")
@RequestMapping(value = "contract")
public class ContractWbsProjectController {

    @Resource
    private TContractWbsProjectService contractWbsProjectService;

    @PostMapping("queryByCode")
    @ApiOperation(value = "根据项目编号查询项目")
    public JsonResult<List<TContractWbsProject>> list(@RequestBody QueryWbsProjectParam param) {
        QueryWrapper<TContractWbsProject> qw = new QueryWrapper<>();
        //TODO 后续处理改为分页模式
        qw.lambda().like(TContractWbsProject::getProjectCode, param.getProjectCode()).last(true,"limit 100");
        return JsonResult.success(contractWbsProjectService.list(qw));
    }

}
